/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.sequence.ui.properties.tabbed;

import org.eclipse.uml2.uml.ConnectableElement;
import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.NamedElement;

import com.cea.papyrus.core.tabbedproperties.AbstractSelectionElementSection;
import com.cea.papyrus.diagram.sequence.ui.filters.ConnectableElementFilter;

/**
 * Property view section to set the represents property of a {@link Lifeline}
 * 
 */
public class LifelineRepresentsSection extends AbstractSelectionElementSection {
	
	public LifelineRepresentsSection() {
		super("Represents:", new ConnectableElementFilter());
	}

	@Override
	public NamedElement getReferencedElementToDisplay() {
		return ((Lifeline) umlElement).getRepresents();
	}

	@Override
	public void removeReferencedElement() {
		((Lifeline) getElement()).setRepresents(null);	
	}

	@Override
	public void setReferencedElement(NamedElement element) {
		if (element instanceof ConnectableElement){
			ConnectableElement connectableElt = (ConnectableElement) element; 
			if (connectableElt!= null) {
				((Lifeline) getElement()).setRepresents(connectableElt);
			}
		}
		
	}
}

